<template>
    <a-modal :title="title" :width="900" :destroyOnClose="true" :maskClosable="false"
             :visible="visible" @cancel="handleCancel" :footer="false"
    >
        <a-table bordered :columns="columns" :rowKey="record => record.id" :dataSource="dataSource"
                 :pagination="pagination" :loading="loading" @change="handleTableChange">
        </a-table>
    </a-modal>
</template>
<script>
    import {pagination, wayStaffTable} from "../public/colums";
    import {wayStaffList} from "../public/http";
    export default {
        props: ["objRecord"],
        data() {
            return {
                loading: false, //按钮Loading
                title: "授权查看",
                visible: true, //modal 显示状态
                dataSource: [],
                pagination: {...pagination}, //复制预设的分页参数
                columns: wayStaffTable, //表头管理
                searchForm: {
                    clientMac:this.objRecord.clientMac,
                    clientName:'',
                    deptCode:'',
                    staffCode:'',
                    staffName:'',
                    positionCode:'',
                },
            };
        },
        methods: {
            //关闭弹窗
            handleCancel() {
                this.visible = false;
                this.$emit('closeModal', {
                    render: false
                });
            },
            //1.0 获取表格数据
            getTableList() {
                this.loading = true;
                let searchData = this.$exMod.filterObjEmpty(this.searchForm); //删除对象中的空值
                wayStaffList(this.pagination, searchData).then(res => {
                    this.loading = false;
                    if (res.code === 0) {
                        this.dataSource = res.data.result; //表格数据
                        this.pagination.total = res.data.total; //总记录条数
                    }
                });
            },
            //1.2翻页监听
            handleTableChange(pagination) {
                this.pagination.current = pagination.current;
                this.pagination.pageSize = pagination.pageSize;
                this.getTableList();
            },
            //3.0 搜索提交
            searchSubmit() {
                this.pagination.current = 1;
                this.getTableList();
            },
            //数据初始化
            async init() {
                this.getTableList();
            }
        },
        created() {
            this.init();
        }
    };
</script>